package appconfig

import (
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		Db       int
	}
	AliYun struct {
		AccessKeyID     string
		AccessKeySecret string
	}
	AliPay struct {
		APPID           string
		AccessKeySecret string
	}
}

var AppConf AppConfig

func SrvViper() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		logx.Error(err)
		panic(err)
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		logx.Error("配置文件读取失败", err)
		panic("配置文件读取失败")
	}
	logx.Info("配置文件读取成功", AppConf)
}
